Skip to content

Add bust_cache param to fix stale featured workshops#1300

Merged
maebeale merged 6 commits intomainfrom
maebeale/fix-featured-workshops
Mar 8, 2026
Merged

Add bust_cache param to fix stale featured workshops#1300
maebeale merged 6 commits intomainfrom
maebeale/fix-featured-workshops

Conversation

@maebeale
Copy link
Collaborator

@maebeale maebeale commented Mar 2, 2026

What is the goal of this PR and why is this important?

  • Featured workshops on the home page can stop appearing due to a stale cache
  • The workshop ID cache (1 year TTL) is invalidated via before_save, which runs inside the save transaction — if another request repopulates the cache before the transaction commits, stale data persists indefinitely

How did you approach the change?

  • Added bust_cache=true URL param support to Home::WorkshopsController — deletes the cached IDs before re-fetching
  • Forwarded the param through the turbo frame in _workshops.html.erb so visiting /?bust_cache=true busts the cache server-wide
  • Added request spec covering the cache bust behavior
  • Documented in README under "Production Maintenance"

UI Testing Checklist

  • Visit / — featured workshops section loads normally
  • Visit /?bust_cache=true — featured workshops appear (cache refreshed)
  • Mark a workshop as featured, visit home — verify it appears (or bust cache if not)

Anything else to add?

  • The caching was introduced in Refactor dashboard lazy load #977 — only workshops use this pattern; stories, community news, and events query the DB directly
  • The before_save → transaction race condition is the root cause, bust_cache is a manual escape hatch

🤖 Generated with Claude Code

maebeale and others added 2 commits March 1, 2026 21:18
Featured workshop IDs are cached for 1 year and the before_save
invalidation can race with the save transaction, leaving stale data.
Visiting /?bust_cache=true now clears and repopulates the cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale changed the title Add bust_cache param to fix stale featured workshops HOLD: Add bust_cache param to fix stale featured workshops Mar 2, 2026
maebeale and others added 2 commits March 8, 2026 08:00
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale changed the title HOLD: Add bust_cache param to fix stale featured workshops Add bust_cache param to fix stale featured workshops Mar 8, 2026
maebeale and others added 2 commits March 8, 2026 13:58
The test env uses :null_store by default, so the stale cache scenario
was untestable — every request re-executed the fetch block.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The workshop factory's before_save callback invalidates the cache
when featured changes, so we manually write stale data back to
simulate the race condition the test is verifying.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@maebeale maebeale merged commit e74353a into main Mar 8, 2026
3 checks passed
@maebeale maebeale deleted the maebeale/fix-featured-workshops branch March 8, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant